package com.atldy.commerce.filter;


import com.atldy.commerce.vo.LoginUserinfo;
import lombok.extern.slf4j.Slf4j;

/**
 * @version 1.0
 * @Author: lidongyang
 * @CreateTime: 2021-08-11 22:11
 * @Description： 使用ThreadLocal存储用户信息
 */
@Slf4j
public class AccessContent {

    private static final ThreadLocal<LoginUserinfo> loginUserinfo = new ThreadLocal<>();

    /**
     * 获取用户信息
     */
    public static LoginUserinfo getLoginUserinfo() {
        log.info(">>>>>从ThreadLocal获取用户信息");
        return loginUserinfo.get();
    }

    /**
     * 设置用户信息
     */
    public static void setLoginUserinfo(LoginUserinfo loginUserinfo_) {
        log.info(">>>>>从ThreadLocal中设置用户信息");
         loginUserinfo.set(loginUserinfo_);
    }

    /**
     * 清除用户信息
     */
    public static void removeLoginUser() {
        log.info(">>>>>从ThreadLocal中清楚用户信息");
        loginUserinfo.remove();
    }

}